#include "cesar.h"
#include <stdlib.h>
#include <stdio.h>
#include "dataProcessing.h"

int
checkCesar (alphabetArray cypherFreq, int size, float tole)
{
   float cypheredIC;
   
   cypheredIC = computeIndexOfCoincidence (cypherFreq, size);
   
   return (cypheredIC / spanishIC * 100 > tole);
}
                 
void
solveCesar(int* s, long size, alphabetArray cypherFreq, int top)
{
   letterStat maxCypher;
   int i, rotation;
   
   maxCypher = getMaxFreq (cypherFreq);
   
   for (i = 0; i < top; i++)
   {
      rotation = maxCypher.c - sortedSpanishFrequencies[i].c;

      if (rotation < 0)
         rotation = ALPHABET_NUM - sortedSpanishFrequencies[i].c + maxCypher.c;
        
      printf("Opcion %d:\n", i+1);
     
      unRotateAndPrint(s, size, rotation);
      
      printf("\n\n");
   }
}
